﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public static class _EX
{
    /// <summary>SQL语句LIKE后使用的字符串参数，例如LIKE '李%'，就是'李'.Like(false, true)</summary>
    /// <param name="key">搜索的关键字</param>
    /// <param name="left">开头是否使用'%'通配符</param>
    /// <param name="right">结尾是否使用'%'通配符</param>
    public static string Like(this string key, bool left = true, bool right = true)
    {
        if (string.IsNullOrEmpty(key)) return null;
        if (left) key = "%" + key;
        if (right) key = key + "%";
        return key;
    }
    /// <summary>SQL语句IN后的参数(SQL 语句需要自带括号，例如 IN (@p0))，数组转换成1,2,3</summary>
    public static string In<T>(this T[] key)
    {
        return string.Join(",", key);
    }
}
